// Decompiled with JetBrains decompiler
// Type: Communication.BaseCommunicationMessageHandlerRegistry
// Assembly: FMCommon, Version=1.0.8663.21262, Culture=neutral, PublicKeyToken=null
// MVID: 52773074-FB09-4BA0-8FA9-4782D11D6C17
// Assembly location: /Users/mac/work/RiverGame/com.rivergame.fmframework/Runtime/Plugins/FMCommon.dll

using System.Collections.Generic;

namespace Communication
{
    public class BaseCommunicationMessageHandlerRegistry : ICommunicationMessageHandlerRegistry
    {
        private Dictionary<string, ICommunicationMessageHandler> handlerMap = new Dictionary<string, ICommunicationMessageHandler>();

        public void RegistMessageHandler(string signature, ICommunicationMessageHandler handler)
        {
            if (this.handlerMap.ContainsKey(signature))
                return;
            this.handlerMap.Add(signature, handler);
        }

        public void UnRegistMessageHandler(string signatrue)
        {
            if (!this.handlerMap.ContainsKey(signatrue))
                return;
            this.handlerMap.Remove(signatrue);
        }

        public ICommunicationMessageHandler GetMessageHandler(
            string signature)
        {
            ICommunicationMessageHandler communicationMessageHandler = (ICommunicationMessageHandler) null;
            this.handlerMap.TryGetValue(signature, out communicationMessageHandler);
            return communicationMessageHandler;
        }

        public void Reset()
        {
            this.handlerMap.Clear();
        }
    }
}
